package com.zhouhailin.shirospringbootdemo.config;

import com.zhouhailin.shirospringbootdemo.interceptor.JWTInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author zhouhailin
 * @date 2023/1/11 15:26
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new JWTInterceptor())
                // 放行，不拦截
                .excludePathPatterns("/token/**")
                .excludePathPatterns("/user/**")
                // 拦截除了"/user/**的所有请求路径
                .addPathPatterns("/**");
    }
}